/**Transcore is a remote-GUI to Transmission.
Copyright (C) 2009 by Jerry de Swart

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package transcore;

import java.io.IOException;
import java.net.URISyntaxException;
import javax.swing.JOptionPane;
import org.json.JSONException;
import org.json.JSONObject;

/**
 *
 * @author J de Swart (Custombuild@gmail.com)
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		String host = JOptionPane.showInputDialog("Host:");
		String username = JOptionPane.showInputDialog("Username:");
		String password = JOptionPane.showInputDialog("Password:");
		try {
			TransConnection conn = TransConnection.createTransConnection(host, 9091, username, password);
			JSONMessage berichtje = new JSONMessage("session-stats");
			JSONObject antwoord = conn.send(berichtje);
			System.out.println(antwoord);
			
			JSONMessage berichtje2 = new JSONMessage("session-get");
			JSONObject antwoord2 = conn.send(berichtje2);
			System.out.println(antwoord2);

            DaemonSettings dInfo = new DaemonSettings();
            dInfo.update(conn);
            System.out.println(dInfo.toString());

			DaemonStats dStats = new DaemonStats();
			dStats.update(conn);
			System.out.println(dStats.toString());

		} catch (URISyntaxException e) {
			System.out.println("URISyntax: " + e.getMessage());
		} catch (IOException e) {
			System.out.println("IOExcept: " + e.getMessage());
		} catch (JSONException e) {
			System.out.println("JSONExcept: " + e.getMessage());
		}
	}
}
